<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <h1>驾校查询</h1>
    <div>
        城区：<select id="cityAreaId">

             </select>
        <input type="button" id="chaxun" value="查询"><br/>
    </div>
    <div>
        <table>
            <thead>
                <tr>
                    <th>驾校名称</th>
                    <th>所在城区</th>
                    <th>地址</th>
                    <th>电话</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody id="ch">

            </tbody>
        </table>
    </div>
    <div>
        <ul id="a"></ul>
    </div>
</body>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    $(function (){
        $.ajax({
            "url":"/KaoShiOne_war_exploded/selCa",
            "type":"post",
            "dataType":"json",
            "success":function(r){
                $('#cityAreaId').html("")
                var data = r.result["list"]
                for(var i = 0; i < data.length; i++){
                    var html2 = "";
                    var num = i+1;
                    html2+='<option value='+num+'>'+data[i].name+'</option>'
                    $('#cityAreaId').append(html2);
                }
            },
            "error":function(){
                alert("服务器错误");
            }
        });
        fenye(1);
    })
    function fenye(page) {
        $.ajax({
            "url":"/KaoShiOne_war_exploded/selDs",
            "type":"get",
            "data":{
                "page":page,
            },
            "dataType":"json",
            "success":function(r){
                $('#ch').html("");
                $('#a').html("");
                var data = r.result["listDs"]
                for(var i = 0; i < data.length; i++){
                    var html = "";
                    html+='<tr>'
                    html+='<td>'+data[i].name+'</td>'
                    var cityName = null;
                    if(data[i].cityAreaid==1){
                        cityName = "芙蓉区";
                    }else if(data[i].cityAreaid==2){
                        cityName = "岳麓区";
                    }else if(data[i].cityAreaid==3){
                        cityName = "望城区";
                    }else if(data[i].cityAreaid==4){
                        cityName = "天心区";
                    }
                    html+='<td>'+cityName+'</td>'
                    html+='<td>'+data[i].address+'</td>'
                    html+='<td>'+data[i].phone+'</td>'
                    html+='<td>'
                    html+='<a href="/KaoShiOne_war_exploded/statics/XiuGai.html?id='+data[i].id+'">修改</a>'
                    html+='</td>'
                    html+='</tr>'
                    $('#ch').append(html);
                }
                var html1 = "";
                html1+='<li><a onclick="fenye('+r.result["p"].firstPage+')">首页</a></li>';
                html1+='<li><a onclick="fenye('+r.result["p"].prePage+')">上一页</a></li>';
                html1+='<li><a onclick="fenye('+r.result["p"].nextPage+')">下一页</a></li>';
                html1+='<li><a onclick="fenye('+r.result["p"].lastPage+')">尾页</a></li>';
                $('#a').append(html1)
            },
            "error":function(){
                alert("服务器错误");
            }
        });
    }

</script>
</html>